
<template>
  <a-modal
    :title="'工艺单列表'"
    :visible="true"
    width="70%"
    :footer="null"
    @cancel="reset"
  >
    <div class="background">
      <a-card>
        <a-table
         v-if="tableType =='N'"
          :loading="loading"
          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange ,type:'radio'}"
          :columns="columns"
          :data-source="tableList"
        >
        </a-table>
         <a-table
        v-else
          :loading="loading"
          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange ,type:'radio'}"
          :columns="columns1"
          :data-source="tableList"
        >
        <!-- <template
          slot="craftBillRelationVos"
          slot-scope="txt, record"
        >
          <a-tag
            v-for="(item,index) in record.craftBillRelationVos"
            :key="index"
            :color="'blue'"
            style="margin-bottom:5px"
          >
            {{item.brandName}}-{{item.xlName}}
          </a-tag>

        </template> -->
        </a-table>
      </a-card>
      <div class="info-action">
        <a-button
          type="primary"
          style="margin-left: 8px"
          @click="submit"
        >
          提交
        </a-button>
      </div>
    </div>
  </a-modal>

</template>

<script>
import { getList,getDictChildList } from '@api/rd/index'

const columns = [
  {
    title: '工艺单号',
    width: 170,
    dataIndex: 'code'
  },
  {
    title: '单据编号',
    width: 140,
    dataIndex: 'billNo'
  },
  {
    title: '上货季',
    dataIndex: 'scseason'
  },
  {
    title: '品牌',
    dataIndex: 'brand'
  },
  {
    title: '小类',
    dataIndex: 'xl'
  },
  {
    title: '样衣号',
    dataIndex: 'sampleCode'
  },
  {
    title: '品名',
    dataIndex: 'sampleName'
  },
  {
    title: '版次',
    dataIndex: 'bc'
  },

]
const columns1 = [
  {
    title: '工艺单号',
    width: 170,
    dataIndex: 'code'
  },
  {
    title: '模板名称',
    dataIndex: 'tempName'
  },
  // {
  //   title: '关联属性',
  //   scopedSlots: { customRender: 'craftBillRelationVos' }

  // },
]
export default {
  components: {},
  props: {
    brandCode: {
      type: String,
      default: null
    },
    xlCode: {
      type: String,
      default: null
    },
    tableType :{
      type: String,
      default: null
    },
  },

  data() {
    return {
      columns,
      columns1,
      nowbrand:'',
      nowXl:'',
      tableList:[],
      selectedRowKeys: [],
      backId: '',
      loading: false
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    reset() {
      this.$emit('closeCopy')
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.backId = selectedRows[0].id
      this.selectedRowKeys = selectedRowKeys
    },
    submit() {
      this.$emit('closeCopy', this.backId)
    },
    handleSubmit(e) {
      e.preventDefault()
    },
     async loadData() {

      const params = {
        current: 1,
        // size: 10,
        xl:this.xlCode,
        brand:this.brandCode,
        isTemp:this.tableType
      }
      try {
        const res = await getList('bill', params)
        if (res.code == 200) {
          this.tableList = res.data.records
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取工艺单列表失败！')
          }
        }
      } catch (error) {
        this.$message.error('获取工艺单列表失败！')
      } finally {
        this.loading = false
      }
    }
  }
}
</script>
<style lang="less" scoped>
.background {
  background: transparent;
}
.ant-modal-body {
  display: flex;
  justify-content: space-between;
}
.info-action {
  display: flex;
  margin-top: 10px;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  // margin-bottom: 20px;
}
</style>